package offer;

public class offerII_0104 {
    public int combinationSum4(int[] nums, int target) {
        int len=nums.length;
        int[][] dp=new int[len][target+1];
        dp[0][0]=1;
        if(nums[0]<=target) dp[0][nums[0]]=1;
        for(int i=1;i<len;++i){
            dp[i][0]=1;
        }
        for(int i=1;i<len;++i){
            for(int j=1;j<target+1;++j){

                for(int k=0;k<=i;++k){
                    if(nums[k]<=j) dp[i][j]+=dp[i][j-nums[k]];
                }
            }
        }
        return dp[len-1][target];
    }
}
